import { fetchData,postData,delData } from '../../api/index';

export default function(){
    let user_url = "/api/user"
    let role_url = "/api/user/roles"
    let getUser = async () => {
        try {
            const res = await fetchData(user_url)
            return res
        } catch (error) {

        }
    }
    let postUser = <T>(login_info:T) => {
        try {
            const res = postData(user_url,login_info)
            return res
        } catch (error) {

        }
    }
    let addUser = <T>(row:T) => {
        try {
            const res = postData(user_url,row)
            return res
        } catch (error) {

        }
    }
    let queryUser = <T>(data:T) => {
        try {
            const res = postData(user_url + "/query",data)
            return res
        } catch (error) {

        }
    } 
    let getRole = async () => {
        try {
            const res = await fetchData(role_url)
            return res
        } catch (error) {

        }
    }
    return { getUser,postUser,queryUser,addUser,getRole }
}